<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
      var arr=[6,9,3,4,5];
      var max = arr[0];
      var min=arr[0];//##不知道为什么var min=max=arr[0],运行出错，
    for(var i=1;i<=arr.length;++i)//出错的点在我把i<=arr.length;写成了arr[i]<=arr.length;
      {
          if(arr[i]>max)
          {
            max=arr[i];

          }
          if(arr[i]<min)
          {
              min=arr[i];
          }

      }  
      console.log('待查找的数组'+arr);
      console.log('最小值：'+min);
      console.log('最大值：'+max);

        
        
        
        
        
        </script>
</body>
</html>